from django.shortcuts import render,redirect
from app.models import User


# Create your views here.

def login(request):

    if request.method == 'GET':
        return render(request, "login.html")
    else:
        username = request.POST.get("username")
        password = request.POST.get("password")

        if User.objects.filter(username=username, password=password):

            return redirect("/main/")
        else:
            return render(request, "login.html", {"msg": "您输入的账号或密码错误！"})

    # 接收界面参数
    # 数据库 orm
    # 跳转页面





# def page(request):
#     print("hanshufangwen")
#     # return render(request,"main.html")
#     # 重定向 redirect
#     return redirect("/main/")
#

def main(request):
    return render(request, "main.html")
